
<%@ page import="coop.bancocredicoop.proyectos.gd.Document" %>
<script>
	function seleccionarCustomer(internalId, name, cuit) {
		$('#customerId').val(internalId)
        var customerDescription = internalId + ' (' + name + ', CUIT: ' + cuit + ')'
		$('#customerDescription').val(customerDescription)
		$('#customer').html(customerDescription)
		$('#buscarClienteModal').modal('hide')
		return false
	}
</script>

<g:if test="${buscarClienteCommand?.hasErrors()}">
	<div class="alert alert-danger">
	<ul class="errors">
	<g:eachError bean="${buscarClienteCommand}" var="error">
		<li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message error="${error}"/></li>
	</g:eachError>
	</ul>
	</div>
</g:if>
<g:else>
			<table class="table table-striped">
				<thead>
					<tr>
						<th>Id</th>
						<th>Nombre</th>
						<th>CUIT</th>
					</tr>
				</thead>
				<tbody>
				<g:each in="${customerInstanceList}" status="i" var="customerInstance">
					<tr>
						<td>
							<a onclick="return seleccionarCustomer('${customerInstance.internalId}', '${customerInstance.name}', '${customerInstance.cuit}')" href="#">
								${fieldValue(bean: customerInstance, field: "internalId")}
							</a>
						</td>
						<td>${fieldValue(bean: customerInstance, field: "name")}</td>
						<td>${fieldValue(bean: customerInstance, field: "cuit")}</td>
					</tr>
				</g:each>
				</tbody>
			</table>
</g:else>